extends "../cTDA_1/cTDA_1.gd"
func _info():
	pass

func _connect():
	._connect()

func _extInit():
	._extInit()
	chaName = "强盗"
	lv = 3
	attCoe.atk = 23 / 8.5 * 2 / 3
	attCoe.maxHp = 800 / 112.5 / 3

	addCdSkill("qd",5)
	addCdSkill("qd2",7)
	addSkillTxt("顺手牵羊：跳到距离自身最远的敌方附近，并对路径上所有人造成50%魔法伤害并附加1层眩晕，每伤害一个敌人则获得2金币[cd:5秒]")
	addSkillTxt("豪夺强取：冲向血量最低的敌方对其造成200%物理伤害并返回，若伤害击杀敌人则获得5金币[cd:7秒]")


func _castCdSkill(id):
	._castCdSkill(id)
	if id == "qd":
		cst("顺手牵羊","000000",position)
		var chas = getAllChas(1)
		chas.sort_custom(self,"sortbydis")
		var cells = self.cell
		jump(chas[0],self)
		self.aiCha = chas[0]
		var chas2 = utils.lineChas(cells,cell,20)
		if chas2.find(chas[0]) == -1:chas2.append(chas[0])
		for i in chas2:
			if i.team == self.team:continue
			i.addBuff(ctrl.b_xuanyun.new(1))
			hurtChara(i,att.atk*0.5,Chara.HurtType.MGI,Chara.AtkType.SKILL)
			if team == 1:
				sys.main.player.plusGold(2)
		
	if id == "qd2":
		cst("豪夺强取","000000",position)
		var chas = getAllChas(1)
		chas.sort_custom(self,"sort")
		var pos = chas[0].position
		ying(pos,position)
		hurtChara(chas[0],att.atk*2,Chara.HurtType.PHY,Chara.AtkType.SKILL)
		ying(position,pos)
		if team == 1 && (!chas[0] || chas[0].att.hp <= 0):
			sys.main.player.plusGold(5)

func sort(a,b):
	return a.att.hp < b.att.hp